<script type="text/javascript">
{literal}
function toggleStatus(obj, urlValue) {
	$(obj).attr('disabled', 'disabled');
	$.ajax({
		url: urlValue ,
		type:'GET',
		success: function(){
			$(obj).removeAttr('disabled');
		}
	});
}
{/literal}
</script>
<div class="mainOptions">
	<h2 class="slidingTab"><a class="colapse" href="#">Szukaj</a></h2>
	<form action="{url category=Search}" method="post">
		<table cellspacing="0" cellpadding="0" border="0" width="100%" class="commonTable">
			<tr>
				<th>Wpisz wyszukiwaną frazę</th>
				<td><input type="text" name="search"/></td>
			</tr>
		</table>
		<p align="right"><input type="submit" value="Szukaj" /></p>
	</form>
</div>

<h1>Kategorie</h1>

{mainoptions title="Lista"}

		<table cellspacing="0" cellpadding="0" border="0">

			<tr>
				<th>{tables type='header' label='Lp.' tid='category_table' noSort=noSort}</th>
				<th>{tables type='header' label='Nazwa' tid='category_table' o='name'}</th>
				<th>{tables type='header' label='Opis' tid='category_table' noSort=noSort}</th>
				<th>{tables type='header' label='Publikuj' tid='category_table' o='status'}</th>
				<th class="noSort"><a href="{url Category=Add}" class="add">Dodaj</a><div class="sort"><a class="ascendingAct" href="#">&nbsp;</a><a class="descending" href="#">&nbsp;</a></div></th>
			</tr>
		{foreach from=$arrayObjCategories item=objCategory key=k name=list}
		{assign var=description value=$objCategory->getCategoryDescription()}
			<tr>
				<td>{tables type='lp' tid='category_table' iteration=$smarty.foreach.list.iteration}<br />[{$objCategory->getId()}]</td>

				<td><a href="{url Category=Edit id=$objCategory->getId()}">{$description->GetName()}</a></td>
				<td>{$description->getDescription()|truncate:300}</td>
				<td>
					<input type="checkbox" {if $objCategory->getActive() == 1}checked="checked"{/if} onchange="toggleStatus(this, '{url Category=ToggleStatus id=$objCategory->getId()}');"/>
				</td>
				<td>
					{if $objCategory->getParent() gt 0}
						<a href="{url Category=VoteIndex id=$objCategory->getId()}" class="edit">oceny cząstkowe</a>
					{/if}
					<a href="{url Category=Edit id=$objCategory->getId()}" class="edit">edytuj</a>
					<a onclick="if(!confirm('Czy na pewno chcesz usunąć ten element?'))return false;" href="{url Category=delete id=$objCategory->getId()}" class="delete">usuń</a>
				</td>
			</tr>
		{/foreach}
			<tr class="selAllRow">
				<td colspan="6">
					<div class="pager">
						{tables type='pagination' tid='category_table' all_count=$c}
						{tables type='on_page' tid='category_table'}
					</div>
				</td>
			</tr>
		</table>

{/mainoptions}
